﻿using Castle.MicroKernel;
using NUnit.Framework;

namespace WindsorInitConfig {
    [TestFixture]
    public class MultipleConstructorsAgain {
        public class ComponentX {}

        public class ComponentY {}

        public class ComponentA {}

        public class Service {
            public ComponentX X { get; private set; }
            public ComponentY Y { get; private set; }
            public ComponentA A { get; private set; }

            public Service(ComponentX x, ComponentY y) {
                X = x;
                Y = y;
            }

            public Service(ComponentA a) {
                A = a;
            }

        }

        [Test]
        public void Kernel_should_select_ctor_with_available_dependencies() {
            var kernel = new DefaultKernel();
            kernel.AddComponent<Service>();
            kernel.AddComponent<ComponentX>();
            kernel.AddComponent<ComponentY>();
            var service = kernel.Resolve<Service>();
            Assert.IsNull(service.A);
            Assert.IsNotNull(service.X);
            Assert.IsNotNull(service.Y);
        }
    }
}